function getPropertyNames(o, a = []) {
  for (const property in o) a.push(property);
  return a;
}
let o = { x: 1 };
let p = { y: 2, z: 3 };
console.log(getPropertyNames(o)); // ['x']
console.log(getPropertyNames(p)); // ['y','z']
